<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/2/12
 * Time: 11:33 AM
 * To change this template use File | Settings | File Templates.
 */
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
$document = JFactory::getDocument();

$hosocanbos = $this->get('hosocanbos');
$pagination = $this->get('pagination');
$session = JFactory::getSession();
$phong = $this->get('phong');
$donvis = $this->get('donvi');
if (count($donvis) > 1)
    $donvi = $donvis[0];
elseif (count($donvis) == 1)
    $donvi = $donvis;
$khoi = $this->get('khoi');

$phonglanhdao = VastHelper::getPhongLanhDao();
if (!(JFactory::getUser()->authorise('vast.phong.quanlyhosocanbo', 'com_vast') && $phonglanhdao->phongid == $phong->id))
{
    JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_vast&view=vast'));                
}

?>

<div id="crumbs">
    <div style="color: #222222;font-weight: normal;margin: 0;padding: 0">
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=vast') ?>">Trang chủ</a> »
        <span>Cơ cấu tổ chức</span> »
        <?php if (isset($khoi)): ?>        
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=donvitructhuoc&id=' . $khoi->id); ?>"><?php echo $khoi->ten ?></a> »                
        <?php endif; ?>
        <?php if (isset($donvi)): ?>
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=phongtructhuocs&id=' . $donvi->id); ?>"><?php echo $donvi->ten ?></a> »
        <?php endif; ?>
        <?php if (isset($phong)): ?>
        <a href="<?php echo JRoute::_('index.php?option=com_vast&view=chitietphong&id=' . $phong->id); ?>"><?php echo $phong->ten ?></a> »        
        <?php endif; ?>
        <span>Cán bộ trực thuộc</span>
    </div>
</div>

<div id="main" class="home">
    <h3 class="title green">Tra cứu thông tin hồ sơ cán bộ của phòng <?php echo $phong->ten; ?></h3>
    <div class="search-form">
        <div class="wide form">
            <form id="commentform" class="commentform" class="form-validate" method="post" action="index.php?option=com_vast&view=quanlycanbophong&context=quanlycanbophong&phongid=<?php echo JRequest::getInt('phongid'); ?>">
    
                <div class="row">
                    <label style="text-align: left;">Họ tên</label>		
                    <input size="60" maxlength="128" name="hosocanboHoten" id="hosocanboHoten" type="text" value="<?php if ($session->get('quanlycanbophong.hoten') !== NULL) echo $session->get('quanlycanbophong.hoten'); ?>"/>	
                </div>
    
                <div class="row">
                    <label style="text-align: left;">Giới tính</label>                
                    <select style="width: 25%;" name="hosocanboGioitinh" id="hosocanboGioitinh">
                        <?php if ($session->get('quanlycanbophong.gioitinh') == 2): ?>
                        <option value="2" selected="selected">-Tất cả-</option>
                        <?php else: ?>
                        <option value="2">-Tất cả-</option>
                        <?php endif; ?>
                        <?php if ($session->get('quanlycanbophong.gioitinh') == 1): ?>
                        <option value="1" selected="selected">Nam</option>
                        <?php else: ?>
                        <option value="1">Nam</option>
                        <?php endif; ?>
                        <?php if ($session->get('quanlycanbophong.gioitinh') == 0): ?>
                        <option value="0" selected="selected">Nữ</option>
                        <?php else: ?>
                        <option value="0">Nữ</option>
                        <?php endif; ?>
                    </select>    
                </div>
    
                <div class="row buttons">
                    <input type="hidden" name="view" value="quanlycanbophong" />
                    <input id="submit" value="Tìm kiếm" type="submit"/>	
                    <?php echo JHtml::_('form.token'); ?>
                </div>
    
            </form>
        </div>
    </div>
    
    <div>
        <table id="rounded-corner">
            <thead>
                <tr>
                    <th scope="col" class="rounded-company"><a href="#hoten">Họ tên</a></th>
                    <th scope="col" class="rounded-q1"><a href="#ngaysinh">Ngày sinh</a></th>
                    <th scope="col" class="rounded-q2"><a href="#nguyenquan">Quê quán</a></th>
                    <th scope="col" class="rounded-q3"><a href="#sodienthoai">Điện thoại</a></th>
                    <th scope="col" class="rounded-q4" style="width: 70px;"><a href="#chucnang">Chức năng</a></th>
                </tr>    
    <!--            <tr>
                    <th scope="col" class="rounded-q1" width="30%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="15%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="15%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="20%"><input type="text"/></th>
                    <th scope="col" class="rounded-q1" width="20%"><input type="text"/></th>
                </tr>-->
            </thead>
            <tfoot>
                <tr>
                    <td colspan="4" class="rounded-foot-left">
                        <em>
                        </em>
                    </td>
                    <td class="rounded-foot-right" style="font-size: smaller;">
                    </td>
                </tr>
            </tfoot>
            <tbody>
                <?php if (count($hosocanbos) > 0): ?>
                <?php foreach ($hosocanbos as $hoso) { ?>
                    <tr>
                        <td><a href="<?php echo JRoute::_('index.php?option=com_vast&view=chitietcanbo&id=' . $hoso->id); ?>"><?= $hoso->hoten ?></a></td>
                        <td><?= date('d/m/Y', strtotime($hoso->ngaysinh)) ?></td>
                        <td><?= $hoso->nguyenquan ?></td>
                        <td><?= $hoso->dienthoai ?></td>
                        <td>
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=chitietcanbo&id=' . $hoso->id); ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/view.png'; ?>" />
                            </a>
                            <?php if (JFactory::getUser()->authorise('vast.hosocanbo.edit', 'com_vast') || (JFactory::getUser()->authorise('vast.hosocanbo.edit.own', 'com_vast') && $hoso->nguoidung_id == JFactory::getUser()->id) || (VastHelper::getPhongTrucThuoc($hoso->id)->id == $phonglanhdao->phongid)): ?>    
                            <a href="<?php echo JRoute::_('index.php?option=com_vast&view=hosocanbo&layout=edit&id=' . $hoso->id); ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/update.png'; ?>" />                            
                            </a>
                            <?php endif; ?>
                            <?php if (JFactory::getUser()->authorise('vast.hosocanbo.delete', 'com_vast') || (VastHelper::getPhongTrucThuoc($hoso->id)->id == $phonglanhdao->phongid)): ?>    
                            <a onclick="return confirm('Bạn có thực sự muốn xóa hồ sơ cán bộ này ra khỏi phòng ?');" href="<?php echo JRoute::_('index.php?option=com_vast&task=quanlycanbophong.delete&id=' . $hoso->id . '&phongid=' . $phong->id); ?>">
                                <img src="<?php echo $this->baseurl . '/components/com_vast/assets/images/delete.png'; ?>" />                            
                            </a>
                            <?php endif; ?>                        
                        </td>
                    </tr>
                <?php } ?>
                <?php endif; ?>
            </tbody>
        </table>
        <div id="tnt_pagination" style="margin-top: 5px;">
        <?php
            echo $pagination->getPagesLinks();
        ?>
        </div>    
    </div>
</div>